plot_round2<-function(mynet,patient0, vaccinated, vulnerable, myname){
  if(missing(vaccinated)) {
    vaccinated=NULL
  }
  if(missing(vulnerable)) {
    vulnerable=NULL
  }

ggraph<-graph_from_adjacency_matrix(as.matrix(mynet), weighted=NULL, mode="undirected",
                                      diag=FALSE)
round1<-setdiff(igraph::neighbors(ggraph,patient0),vaccinated)
#round1<-setdiff(names(as.matrix(mynet)[patient0,][as.matrix(mynet)[patient0,]==1]),vaccinated)

#round2<-NULL
#for (i in round1){
#  r2<-igraph::neighbors(ggraph,i)
#  round2<-c(round2,r2)
#}

#round2<-unique(round2)
#round2<-setdiff(round2,c(round1,vaccinated,patient0))


mynet1<-as.matrix(mynet)
mynet1[vaccinated,]<-0
mynet1[,vaccinated]<-0

g.sim2<-as.matrix(mynet1)%*%as.matrix(mynet1)
diag(g.sim2)<-0
round2<-names(as.matrix(g.sim2)[patient0,][as.matrix(g.sim2)[patient0,]>0])
round2<-setdiff(round2,c(round1,vaccinated,patient0))

ggraph<-graph_from_adjacency_matrix(as.matrix(mynet), weighted=NULL, mode="undirected",
                                    diag=FALSE)
set.seed(1413)
LO = layout_with_fr(ggraph)
vertex_attr(ggraph, "vulnerable") <- 0
vertex_attr(ggraph, "vulnerable", index = vulnerable) <- 1
vertex_attr(ggraph, "round1") <- 0
vertex_attr(ggraph, "round1", index = round1) <- 1
vertex_attr(ggraph, "round2") <- 0
vertex_attr(ggraph, "round2", index = round2) <- 1
  if(!missing(vaccinated)){
    vertex_attr(ggraph, "vaccinated") <- 0
    vertex_attr(ggraph, "vaccinated", index = vaccinated) <- 1
  }

V(ggraph)$color <- ifelse(vertex_attr(ggraph,"round1") == 1, "red", "grey")
V(ggraph)$frame.color<-ifelse(vertex_attr(ggraph,"vulnerable") == 1, "green","black")
V(ggraph)$frame.width<-ifelse(vertex_attr(ggraph,"vulnerable") == 1, 1.5,.5)


V(ggraph)$color[vertex_attr(ggraph,"round2") == 1] <- "orange"
 if(!missing(vaccinated)){
    V(ggraph)$color[vertex_attr(ggraph,"vaccinated") == 1] <- "blue"
  }
V(ggraph)$color[vertex_attr(ggraph,"name") == as.character(patient0)] <- "darkred"
subt=as.character(paste0("Infected: ",length(round1)+length(round2)))
plot(ggraph, vertex.size=15, vertex.color=V(ggraph)$color, frame.color=V(ggraph)$frame.color,
     frame.width=V(ggraph)$frame.width,
     vertex.label=NA,label.color="white",layout=LO)
title(myname,cex.main=.8)
text(.9,-1,subt)
}

#plot_round2(mynet=g.sim,patient0=36, vaccinated=vaccine_close, myname="Closeness")
